package com.cq.hd.member.api.vo;

import com.cq.hd.common.enums.biz.WithdrawalCheckItemTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author much
 * @since 2024/04/19 22:38
 */
@Data
public class WithdrawalCheckBillInitVo implements Serializable {
    private static final long serialVersionUID = 4984960823004815138L;

    @ApiModelProperty(value = "核算单id")
    private Long id;

    @ApiModelProperty(value = "提现金额")
    private BigDecimal withdrawalAmt;

    @ApiModelProperty(value = "结算金额")
    private BigDecimal finalAmt;

    @ApiModelProperty(value = "核算类型：1-本金 2-补贴")
    private Integer checkType;

    @ApiModelProperty(value = "明细")
    private List<WithdrawalCheckItemVo> items;

    @ApiModelProperty(value = "结算账单明细（本金不展示）")
    public List<WithdrawalCheckItemVo> getBillItems() {
        if (checkType == 1) {
            return Collections.emptyList();
        }
        if (CollectionUtils.isEmpty(items)) {
            return Collections.emptyList();
        }
        return items.stream()
                .filter(e -> e.getType() == WithdrawalCheckItemTypeEnum.MERCHANT_SUBSIDY.getValue())
                .collect(Collectors.toList());
    }

    @ApiModelProperty(value = "费用明细")
    public List<WithdrawalCheckItemVo> getFeeItems() {
        List<Integer> feeTypes = Arrays.asList(
                WithdrawalCheckItemTypeEnum.FEE.getValue(), WithdrawalCheckItemTypeEnum.DEDUCTION.getValue(), WithdrawalCheckItemTypeEnum.ADD.getValue());
        if (CollectionUtils.isEmpty(items)) {
            return Collections.emptyList();
        }
        return items.stream()
                .filter(e -> feeTypes.contains(e.getType()))
                .collect(Collectors.toList());
    }

}
